package io.unicorn.modules.waterfgs.service.impl;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.unicorn.common.utils.PageUtils;
import io.unicorn.common.utils.Query;

import io.unicorn.modules.waterfgs.dao.DataErrAlertFixedFgsDao;
import io.unicorn.modules.waterfgs.entity.DataErrAlertFixedFgsEntity;
import io.unicorn.modules.waterfgs.service.DataErrAlertFixedFgsService;


@Service("dataErrAlertFixedFgsService")
public class DataErrAlertFixedFgsServiceImpl extends ServiceImpl<DataErrAlertFixedFgsDao, DataErrAlertFixedFgsEntity> implements DataErrAlertFixedFgsService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        //查找部门ID
        String unitId = params.get("unitId").toString();

        String deptId = (String)params.get("dept");
        String key   = (String)params.get("key");
        String value = (String)params.get("value");

        IPage<DataErrAlertFixedFgsEntity> page = this.page(
                new Query<DataErrAlertFixedFgsEntity>().getPage(params),
                new QueryWrapper<DataErrAlertFixedFgsEntity>()
                        .eq("unit_id",unitId)
                        .like(StringUtils.isNotEmpty(deptId),"dept_id", deptId)
                        .like(StringUtils.isNotBlank(value) && StringUtils.isNotBlank(key), key, value)
                        .apply("pro_name not  in (select 小区名称 from [Gather_DB].[dbo].[v_stop_view_data])")
        );

        return new PageUtils(page);
    }

}
